<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">




<script>
    (function(){
        if(''){
            if (prompt('请输入文章密码') !== ''){
                alert('密码错误！');
                history.back();
            }
        }
    })();
  </script>






<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />



  <link rel="icon" type="image/png" sizes="32x32" href="/favicon.ico?v=5.1.4">







  <meta name="keywords" content="Swift," />





  <link rel="alternate" href="/atom.xml" title="Swift社区" type="application/atom+xml" />






<meta name="description" content="前言本期是 Swift 编辑组自主整理周报的第十八期，每个模块已初步成型。各位读者如果有好的提议，欢迎在文末留言。 Swift 周报在 GitHub 开源，欢迎提交 issue，投稿或推荐内容。目前计划每两周周一发布，欢迎志同道合的朋友一起加入周报整理。 再暗的黑夜也会迎来黎明，再长的坎坷也会连接平川。怀抱Swift社区，一颗永不放弃的希望之心，明天将会是温暖的阳光雨露！👊👊👊  周报精选">
<meta name="keywords" content="Swift">
<meta property="og:type" content="article">
<meta property="og:title" content="Swift 周报 第二十七期">
<meta property="og:url" content="https://fanbaoying.github.io/Swift-周报-第二十七期/index.html">
<meta property="og:site_name" content="Swift社区">
<meta property="og:description" content="前言本期是 Swift 编辑组自主整理周报的第十八期，每个模块已初步成型。各位读者如果有好的提议，欢迎在文末留言。 Swift 周报在 GitHub 开源，欢迎提交 issue，投稿或推荐内容。目前计划每两周周一发布，欢迎志同道合的朋友一起加入周报整理。 再暗的黑夜也会迎来黎明，再长的坎坷也会连接平川。怀抱Swift社区，一颗永不放弃的希望之心，明天将会是温暖的阳光雨露！👊👊👊  周报精选">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://jg-app.obs.cn-north-4.myhuaweicloud.com/prod/upload/jpg/0a52d53f56fb4270855286d10f80f239.jpg">
<meta property="og:image" content="https://devimages-cdn.apple.com/wwdc-services/articles/images/1FFB9751-9FB2-4171-B6E2-14CF821F6887/2048.jpeg">
<meta property="og:image" content="https://user-images.githubusercontent.com/24238160/132703149-34121c6c-fd18-491c-a697-58a0fabf3060.png">
<meta property="og:updated_time" content="2023-07-04T07:29:17.006Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Swift 周报 第二十七期">
<meta name="twitter:description" content="前言本期是 Swift 编辑组自主整理周报的第十八期，每个模块已初步成型。各位读者如果有好的提议，欢迎在文末留言。 Swift 周报在 GitHub 开源，欢迎提交 issue，投稿或推荐内容。目前计划每两周周一发布，欢迎志同道合的朋友一起加入周报整理。 再暗的黑夜也会迎来黎明，再长的坎坷也会连接平川。怀抱Swift社区，一颗永不放弃的希望之心，明天将会是温暖的阳光雨露！👊👊👊  周报精选">
<meta name="twitter:image" content="https://jg-app.obs.cn-north-4.myhuaweicloud.com/prod/upload/jpg/0a52d53f56fb4270855286d10f80f239.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://fanbaoying.github.io/Swift-周报-第二十七期/"/>





  <title>Swift 周报 第二十七期 | Swift社区</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
    
    <a href="https://github.com/SwiftCommunityRes" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
    
    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Swift社区</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">做最好的 Swift 社区</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://fanbaoying.github.io/Swift-周报-第二十七期/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Swift社区">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="https://avatars.githubusercontent.com/u/84354365?v=4">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Swift社区">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Swift 周报 第二十七期</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2023-07-04T15:19:58+08:00">
                2023-07-04
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Swift-周报/" itemprop="url" rel="index">
                    <span itemprop="name">Swift 周报</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>

                <!-- 
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                -->
                <span title="字数统计">
                  数字统计 3,925字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>

                <!-- 
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                --> 

                <span title="阅读时长">
                  阅读时长 15分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p><strong>本期是 Swift 编辑组自主整理周报的第十八期</strong>，每个模块已初步成型。各位读者如果有好的提议，欢迎在文末留言。</p>
<p>Swift 周报在 <a href="https://github.com/SwiftCommunityRes/SwiftWeekly" title="SwiftWeekly" target="_blank" rel="noopener">GitHub 开源</a>，欢迎提交 issue，投稿或推荐内容。目前计划每两周周一发布，欢迎志同道合的朋友一起加入周报整理。</p>
<p>再暗的黑夜也会迎来黎明，再长的坎坷也会连接平川。怀抱<strong>Swift社区</strong>，一颗永不放弃的希望之心，明天将会是温暖的阳光雨露！👊👊👊</p>
<blockquote>
<p><strong>周报精选</strong></p>
<p>新闻和社区：因增速放缓 苹果公司将开启大规模收购</p>
<p>提案：Package Manager 支持自定义宏</p>
<p>Swift 论坛：讨论为什么 didSet 观察者在使用中会触发 Set 类型的属性</p>
<p>推荐博文：在 SwiftUI 中掌握 Canvas 的使用</p>
<p><strong>话题讨论：</strong> </p>
<p>你存钱了吗？你存钱的目的是什么呢？</p>
</blockquote>
<a id="more"></a>
<h2 id="新闻和社区"><a href="#新闻和社区" class="headerlink" title="新闻和社区"></a>新闻和社区</h2><h3 id="苹果公司向“恢复基金”再投2亿美元，推进碳移除项目"><a href="#苹果公司向“恢复基金”再投2亿美元，推进碳移除项目" class="headerlink" title="苹果公司向“恢复基金”再投2亿美元，推进碳移除项目"></a>苹果公司向“恢复基金”再投2亿美元，推进碳移除项目</h3><p><img src="https://jg-app.obs.cn-north-4.myhuaweicloud.com/prod/upload/jpg/0a52d53f56fb4270855286d10f80f239.jpg" alt=""></p>
<p>据界面新闻消息，苹果公司 4 月 12 日宣布，在最初 2 亿美元的投资基础上，将向 2021 年设立的“恢复基金”（Restore Fund）再投多达 2 亿美元。该基金旨在为高质量的自然碳移除项目提供资金，激励全球投资保护和恢复“关键生态系统”。苹果公司还希望帮助无法通过现有技术避免或减少碳排放的企业，推广可行的碳移除解决方案。</p>
<p>加码后的基金将由汇丰资产管理部门和 Polliation 合资成立的 Climate Asset Management 管理，额外投资预计将使苹果此前提出的每年从大气中清除 100 万公吨二氧化碳目标翻倍，同时为投资者带来经济回报。</p>
<p>该基金期望把重点放在面向自然的农业项目以及保护和恢复关键生态系统的项目上，前者将帮助公司从可持续管理的农业实践中获得收入，后者则能从大气中移除并储存二氧化碳。苹果公司表示，“恢复基金”的投资将遵循“严格的社会和环境标准”。</p>
<h3 id="因增速放缓-苹果公司将开启大规模收购"><a href="#因增速放缓-苹果公司将开启大规模收购" class="headerlink" title="因增速放缓 苹果公司将开启大规模收购"></a>因增速放缓 苹果公司将开启大规模收购</h3><p>【环球网科技综合报道】4 月 7 日消息，据外媒报道称，苹果公司目前拥有超过 1650 亿美元的现金储备，鉴于苹果公司当前增速放缓，这家公司未来会开启大规模的收购。</p>
<p>不过，和微软、亚马逊等大手笔收购类型不同，苹果公司更倾向于收购小型初创公司。</p>
<p>外媒称，苹果喜欢以培养、孵化的方式开展收购，并耐心等待这些初创公司成长，来撬动新的市场。</p>
<p>据此前报道，今年 2 月，苹果收购了位于加州的 AI 算法公司 WaveOne 。今年 3 月，苹果公司已经收购了英国开放银行初创公司 CreditKudos 。</p>
<p>据了解，苹果经常收购小型企业，以加强其技术和专业知识，但显然没有或立即将其推广到产品或服务中。另一方面，许多收购确实成为苹果生态系统的关键部分。近年来，苹果已经收购了音乐识别服务 Shazam 和自动驾驶汽车公司 Drive.ai 等企业。</p>
<h3 id="Swift-Student-Challenge-现已开放申请"><a href="#Swift-Student-Challenge-现已开放申请" class="headerlink" title="Swift Student Challenge 现已开放申请"></a>Swift Student Challenge 现已开放申请</h3><p><img src="https://devimages-cdn.apple.com/wwdc-services/articles/images/1FFB9751-9FB2-4171-B6E2-14CF821F6887/2048.jpeg" alt=""></p>
<p>我们很高兴能一如既往地为世界各地热爱编程的学生提供长期支持。欢迎使用 Swift Playgrounds 或 Xcode 编写 App Playground (主题自选) 并提交你的杰作，向我们展现你对于编程的热爱。优胜者将获得奖项和表彰，以及额外奖励。</p>
<h2 id="提案"><a href="#提案" class="headerlink" title="提案"></a>提案</h2><h3 id="通过的提案"><a href="#通过的提案" class="headerlink" title="通过的提案"></a>通过的提案</h3><p><a href="https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md" title="SE-0393" target="_blank" rel="noopener">SE-0393</a> <strong>Value 和 Type 参数包</strong> 提案通过审查。该提案已在 <strong>二十六期周报</strong> 正在审查的提案模块做了详细介绍。</p>
<h3 id="正在审查的提案"><a href="#正在审查的提案" class="headerlink" title="正在审查的提案"></a>正在审查的提案</h3><p><a href="https://github.com/apple/swift-evolution/blob/main/proposals/0394-swiftpm-expression-macros.md" title="SE-0394" target="_blank" rel="noopener">SE-0394</a> <strong>Package Manager 支持自定义宏</strong> 提案正在审查。</p>
<p>宏提供了一种扩展 Swift 的方法，通过对输入源代码执行任意语法转换来生成新代码。该提案涵盖了如何将自定义宏作为 Swift 软件包的一部分进行定义、构建和分发。</p>
<p><a href="https://github.com/apple/swift-evolution/blob/main/proposals/0395-observability.md" title="SE-0395" target="_blank" rel="noopener">SE-0395</a> <strong>Observation</strong> 提案正在审查。</p>
<p>该提案定义了什么是可观察的引用，观察者需要遵守什么，以及类型与其观察者之间的联系。这种设计模式是许多语言都支持的，Swift 引入之后，无疑将更加强大、安全和高性能。</p>
<h2 id="Swift论坛"><a href="#Swift论坛" class="headerlink" title="Swift论坛"></a>Swift论坛</h2><p>1) 提议<a href="https://forums.swift.org/t/pitch-variadic-generic-types-abstracting-over-packs/64377" title="可变泛型类型抽象包" target="_blank" rel="noopener">可变泛型类型抽象包</a></p>
<p><strong>介绍</strong></p>
<p>之前的 SE-0393 引入了类型参数包和几个相关概念，允许泛型函数声明抽象出可变数量的类型。 该提案将这些想法概括为泛型类型声明。</p>
<p><strong>动机</strong></p>
<p>当试图在集合上概括通用算法时，自然会出现对可变数量的类型进行抽象的通用类型声明。 例如，惰性 ZipSequence 可能在两个序列上是通用的。 可以声明一个 ZipSequence 类型，它将固定序列列表的元素表示为元组序列：</p>
<figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">ZipSequence</span>&lt;<span class="title">each</span> <span class="title">S</span>: <span class="title">Sequence</span>&gt;: <span class="title">Sequence</span> </span>&#123;</span><br><span class="line">  <span class="keyword">typealias</span> <span class="type">Element</span> = (<span class="keyword">repeat</span> each <span class="type">S</span>.<span class="type">Element</span>)</span><br><span class="line"></span><br><span class="line">  <span class="keyword">let</span> seq: (<span class="keyword">repeat</span> each <span class="type">S</span>)</span><br><span class="line"></span><br><span class="line">  <span class="function"><span class="keyword">func</span> <span class="title">makeIterator</span><span class="params">()</span></span> -&gt; <span class="type">Iterator</span> &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="type">Iterator</span>(iter: (<span class="keyword">repeat</span> (each seq).makeIterator()))</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="class"><span class="keyword">struct</span> <span class="title">Iterator</span>: <span class="title">IteratorProtocol</span> </span>&#123;</span><br><span class="line">    <span class="keyword">typealias</span> <span class="type">Element</span> = (<span class="keyword">repeat</span> each <span class="type">S</span>.<span class="type">Element</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">var</span> iter: (<span class="keyword">repeat</span> each <span class="type">S</span>.<span class="type">Iterator</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">mutating</span> <span class="function"><span class="keyword">func</span> <span class="title">next</span><span class="params">()</span></span> -&gt; <span class="type">Element</span>? &#123;</span><br><span class="line">      <span class="keyword">return</span> ...</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>建议的解决方案</strong></p>
<p>在泛型类型的泛型参数列表中，each 关键字声明了一个泛型参数包，就像它在泛型函数的泛型参数列表中所做的那样。 存储属性的类型可以包含包扩展类型，如上面的 let seq 和 var iter。</p>
<p>2) 讨论<a href="https://forums.swift.org/t/dot-prefixing-considered-ugly/64376" title="点前缀被认为是丑陋的" target="_blank" rel="noopener">点前缀被认为是丑陋的</a></p>
<p>虽然我们已经习惯了，但在静态成员和枚举常量前加上点会引入视觉噪音，看起来太聪明了，总是让我的其他语言背景的同事感到惊讶：</p>
<figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">foo</span><span class="params">(<span class="number">_</span> v: Color)</span></span> &#123;...&#125;</span><br><span class="line">object.foo(.red) <span class="comment">// 🤔</span></span><br></pre></td></tr></table></figure>
<p>在声明中缺少点前缀之间也存在这种令人不安的不对称性：</p>
<figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">enum</span> <span class="title">Color</span> </span>&#123;</span><br><span class="line">    <span class="keyword">case</span> red</span><br><span class="line">    <span class="keyword">case</span> green</span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">var</span> blue = ...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>并在其他地方使用这些前缀：</p>
<figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">switch</span> color &#123;</span><br><span class="line">    <span class="keyword">case</span> .red: <span class="keyword">break</span></span><br><span class="line">    <span class="keyword">case</span> .green: <span class="keyword">break</span></span><br><span class="line">&#125;</span><br><span class="line">foo(.red)</span><br><span class="line">foo(.blue)</span><br></pre></td></tr></table></figure>
<p>有趣的是，我已经可以在某些上下文中使用“object.foo(red)”（例如，在 Color 的静态方法中），但不能在其他上下文中使用。</p>
<p>我很欣赏这将是一个突破性的变化，我们不可能在现阶段迅速适应这一变化。 暂时忘记这一点，你认为 Swift 通过以下更改会变得更好还是更糟？</p>
<figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">foo</span><span class="params">(<span class="number">_</span> v: Color)</span></span> &#123;...&#125;</span><br><span class="line">...</span><br><span class="line">object.foo(<span class="type">Color</span>.red) <span class="comment">// ok</span></span><br><span class="line">object.foo(.red)      <span class="comment">// 🛑 prohibited</span></span><br><span class="line">object.foo(red)       <span class="comment">// ✅</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">switch</span> color &#123;</span><br><span class="line">    <span class="keyword">case</span> .red: <span class="keyword">break</span>  <span class="comment">// 🛑 prohibited</span></span><br><span class="line">    <span class="keyword">case</span> red: <span class="keyword">break</span>   <span class="comment">// ✅</span></span><br><span class="line">&#125;</span><br><span class="line">dispatchPrecondition(condition: .onQueue(.main)) <span class="comment">// 🛑</span></span><br><span class="line">dispatchPrecondition(condition: onQueue(main))   <span class="comment">// ✅</span></span><br><span class="line">bar(.<span class="keyword">init</span>()) <span class="comment">// 🛑</span></span><br><span class="line">bar(<span class="keyword">init</span>())  <span class="comment">// ✅</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// While choosing what "red" to use – follow these new resolution rules:</span></span><br><span class="line"><span class="comment">// - use local variable if exists</span></span><br><span class="line"><span class="comment">// - or use instance variable if exists (in which case self should be captured strongly explicitly or implicitly)</span></span><br><span class="line"><span class="comment">// - or use static variable if exists (in case of enum could be an enumeration constant)</span></span><br><span class="line"><span class="comment">// - or use global variable if exists</span></span><br><span class="line"><span class="comment">// - otherwise emit an error</span></span><br></pre></td></tr></table></figure>
<p>3) 讨论<a href="https://forums.swift.org/t/can-non-sendable-types-be-captured-in-tasks/64372" title="非 Sendable 类型可以在 Tasks 中捕获吗？" target="_blank" rel="noopener">非 Sendable 类型可以在 Tasks 中捕获吗？</a></p>
<p>现在，我猜想下面的代码应该会出现任何错误。</p>
<figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">SomeClass</span> </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> <span class="built_in">count</span>: <span class="type">Int</span></span><br><span class="line">    <span class="keyword">init</span>(<span class="built_in">count</span>: <span class="type">Int</span>) &#123;</span><br><span class="line">        <span class="keyword">self</span>.<span class="built_in">count</span> = <span class="built_in">count</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">let</span> someClass = <span class="type">SomeClass</span>(<span class="built_in">count</span>: <span class="number">0</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">//public init(priority: TaskPriority? = nil, operation: @escaping @Sendable () async -&gt; Success)</span></span><br><span class="line"><span class="type">Task</span> &#123;</span><br><span class="line">    someClass.<span class="built_in">count</span> += <span class="number">1</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//public init(priority: TaskPriority? = nil, operation: @escaping @Sendable () async -&gt; Success)</span></span><br><span class="line"><span class="type">Task</span> &#123;</span><br><span class="line">    someClass.<span class="built_in">count</span> += <span class="number">1</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>但是，在 Swift（5.8 版）中，此代码片段可以编译。 在 Swift6 中，这段代码有没有出现错误？</p>
<p><strong>回答：</strong></p>
<p>在 Swift v.Future 中，全局 someClass 必须与全局 actor 隔离，因此行 someClass.count += 1 将需要：</p>
<p>整个 Task 闭包被隔离到同一个global actor，或者您为该操作切换到适当的global actor<br>（例如：await MainActor.run { someClass.count += 1 }）很难准确地说出在 Swift 6 中什么会/不会是错误。您可以使用一些编译器标志来尝试一些事情，但它们是不一致的。</p>
<p>4) 讨论<a href="https://forums.swift.org/t/why-does-didset-observer-fire-for-property-of-type-set-after-calling-insert-with-value-already-in-the-set/64350" title="为什么 didSet 观察者在使用集合中已有的值调用插入后会触发 Set 类型的属性？" target="_blank" rel="noopener">为什么 didSet 观察者在使用集合中已有的值调用插入后会触发 Set 类型的属性？</a></p>
<p>Xcode Playground 中的以下代码片段：</p>
<figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> UIKit</span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> collection = <span class="type">Set</span>&lt;<span class="type">String</span>&gt;() &#123;</span><br><span class="line">    <span class="keyword">didSet</span> &#123;</span><br><span class="line">        <span class="built_in">print</span>(<span class="string">"didSet"</span>)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">collection.insert(<span class="string">"Test1"</span>)</span><br><span class="line">collection.insert(<span class="string">"Test2"</span>)</span><br><span class="line">collection.insert(<span class="string">"Test1"</span>)</span><br><span class="line">collection.insert(<span class="string">"Test3"</span>)</span><br><span class="line"></span><br><span class="line"><span class="built_in">print</span>(<span class="string">"Done"</span>)</span><br></pre></td></tr></table></figure>
<p>为什么是输出：</p>
<figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">didSet</span></span><br><span class="line"><span class="keyword">didSet</span></span><br><span class="line"><span class="keyword">didSet</span></span><br><span class="line"><span class="keyword">didSet</span></span><br><span class="line"><span class="type">Done</span></span><br></pre></td></tr></table></figure>
<p>而不是:</p>
<figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">didSet</span></span><br><span class="line"><span class="keyword">didSet</span></span><br><span class="line"><span class="keyword">didSet</span></span><br><span class="line"><span class="type">Done</span></span><br></pre></td></tr></table></figure>
<p>为什么当集合未更改时它会触发，因为该值已经在集合中？</p>
<p><strong>回答：</strong></p>
<p>每个mutating函数都会像这样。<br>没有特殊的机制可以让属性知道 Set 没有在内部被修改。</p>
<p>5) 讨论<a href="https://forums.swift.org/t/a-simultaneously-simple-yet-probably-fatally-complex-use-of-variadic-generics/64347" title="可变参数泛型的同时简单但可能致命复杂的使用" target="_blank" rel="noopener">可变参数泛型的同时简单但可能致命复杂的使用</a></p>
<p>我很好奇即将到来的可变参数泛型特性是否能让我们实现像 transform(<em>:</em>:) 这样的函数，你可以在下面看到它的使用：</p>
<figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">extension</span> <span class="title">String</span> </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> hasPrimeNumberOfCharacters: <span class="type">Bool</span> &#123;</span><br><span class="line">        transform(</span><br><span class="line">            <span class="keyword">self</span>,</span><br><span class="line">            &#123; $<span class="number">0</span>.<span class="built_in">count</span> &#125;,</span><br><span class="line">            &#123; $<span class="number">0</span>.isPrime &#125;</span><br><span class="line">        )</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>该函数采用一个强制性的第一个参数，即要转换的值，然后是一个可变的转换闭包列表，每个闭包都对它之前的闭包的输出类型进行操作，第一个对初始值进行操作。 在上面的例子中，参数是：String, (String)-&gt;Int, (Int)-&gt;Bool。</p>
<p>我已经阅读了大量的可变参数泛型文档，如果我现在必须给出我最好的猜测，我会说我的 transform(<em>:</em>:) 函数在可变参数泛型的第一次迭代中是不可能的。</p>
<p>下面是一个非常粗略的草图，它是我能想象到的最接近如何编写这样一个函数签名的草图。 我发现有必要发明许多新的语法，这支持了我的猜测，即这是不可能的，至少在最初是不可能的。</p>
<figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">transform</span></span></span><br><span class="line"><span class="function">    &lt;InitialValue,</span></span><br><span class="line"><span class="function">     each (T, U)&gt;</span></span><br><span class="line"><span class="function">    <span class="params">(<span class="number">_</span> initialValue: InitialValue,</span></span></span><br><span class="line"><span class="function"><span class="params">     <span class="number">_</span> transform: <span class="keyword">repeat</span> each <span class="params">(T)</span></span></span>-&gt;<span class="type">U</span>)</span><br><span class="line">-&gt; last <span class="type">U</span> or <span class="type">InitialValue</span></span><br><span class="line"><span class="keyword">where</span> first <span class="type">T</span> == <span class="type">InitialValue</span> &#123;</span><br><span class="line">    <span class="comment">// How would one even implement this if the above syntax were valid?</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>6) 讨论<a href="https://forums.swift.org/t/building-distros-for-debian-ubuntu/64367" title="为 Debian/Ubuntu 构建发行版？" target="_blank" rel="noopener">为 Debian/Ubuntu 构建发行版？</a></p>
<p>现在我希望在 Jetson Nano（它有一个 ARM Cortex-A57 CPU）上用 Swift 做一个机器人项目，它只能使用 Ubuntu 18.04。 18.04 没有预构建的 5.8 .deb 包，这有点痛苦，因为这意味着我必须从源代码构建，并且一些构建依赖项（例如 cmake）必须从源代码构建才能获得最新的 足够的版本。 我以前构建过工具链，现在我正在 Jetson Nano 上构建它，但它花费了很长时间，尽管构建在连接的 SSD 上（操作系统运行在 SD 卡上）。</p>
<p>我想知道在我的 M1 Max MacBook Pro 上的 Ubuntu 18.04 Docker 容器（或者可能是 Parallels VM）中构建工具链是否有意义，然后构建将正确安装在任何 18.04 ARM 机器上的工具链的 .deb。</p>
<p>你认为那会建造得更快吗？</p>
<p>是否存在对构建 .deb 包的支持？ 20.04 和 22.04 包是如何构建的？</p>
<p><strong>回答：</strong></p>
<p>另一种选择是构建 MacOS -&gt; 18.04 交叉编译工具链。 不久前，我将 x-compiler 配置移到了 focus，但要翻转回 bionic 配置应该很容易。</p>
<p>7) 发布<a href="https://forums.swift.org/t/swift-5-8-released/64346" title="Swift 5.8 发布！" target="_blank" rel="noopener">Swift 5.8 发布！</a></p>
<p><strong>链接：</strong> <a href="https://www.swift.org/blog/swift-5.8-released/" target="_blank" rel="noopener">https://www.swift.org/blog/swift-5.8-released/</a></p>
<p>您可能已经看到，Swift 5.8 现已正式发布！ :tada: 此版本包括对语言和标准库的主要补充，包括支持逐步采用即将推出的功能的 hasFeature、改进的开发人员体验、改进 Swift 生态系统中的工具，包括 Swift-DocC、Swift Package Manager 和 SwiftSyntax，经过改进 Windows 支持等。</p>
<h2 id="推荐博文"><a href="#推荐博文" class="headerlink" title="推荐博文"></a>推荐博文</h2><p><a href="https://swiftwithmajid.com/2023/04/11/mastering-canvas-in-swiftui/" title="在 SwiftUI 中掌握 Canvas 的使用" target="_blank" rel="noopener">在 SwiftUI 中掌握 Canvas 的使用</a></p>
<p><strong>摘要：</strong> 文章介绍了如何使用 Canvas 视图在 SwiftUI 中绘制 2D 图形，而无需使用 Shape API 。在 Canvas 视图中，我们可以使用 GraphicsContext 实例进行绘图，调整透明度、缩放和混合模式等参数，并添加不同的滤镜。 Canvas 还提供了 stroke、 fill 和 clip 函数，允许我们绘制任何我们需要的路径，同时也提供了draw函数，允许我们绘制文本和图像。我们可以使用 Canvas 类型绘制任何 SwiftUI 视图，但需要在创建 Canvas 时使用 symbols 闭包中注册它们。虽然 Canvas 视图不支持动画，但可以通过将其嵌入到带有动画调度程序的 TimelineView 中来实现动画效果。 Canvas 视图没有辅助功能树，但可以附加一组辅助视图修饰符，以使每个人都可以访问其内容。</p>
<p><a href="https://www.swiftbysundell.com/articles/observing-swiftui-scrollview-content-offset/#resolving-frames-using-geometryreader" title="监听 SwiftUI ScrollView 的内容偏移量" target="_blank" rel="noopener">监听 SwiftUI ScrollView 的内容偏移量</a></p>
<p><strong>摘要：</strong> 文章介绍了如何监听 SwiftUI ScrollView 的内容偏移量。在构建可滚动的 UI 时，通常需要观察当前滚动位置以便进行操作，但目前（在撰写本文时）SwiftUI 的 ScrollView 没有内置的方式来执行此类滚动观察。作者提供了一种利用 GeometryReader 解析器并使用 PreferenceKey 类型来实现的方法，使我们能够观察当前的内容偏移。最终作者实现了一个名为 OffsetObservingScrollView 的自定义滚动视图，可以实现监听当前内容偏移量的功能。</p>
<p><a href="https://www.swiftbysundell.com/articles/opaque-return-types-primary-associated-types/" title="Swift 中如何将不透明返回类型与主要关联类型相结合" target="_blank" rel="noopener">Swift 中如何将不透明返回类型与主要关联类型相结合</a></p>
<p><strong>摘要：</strong>  文章介绍了 Swift 5.7 引入的主关联类型和不透明返回类型相结合的使用方式。通过声明主关联类型，我们可以在使用 some 关键字时避免类型擦除，并使代码更加类型安全。该功能不仅适用于 Combine 框架，还可以在处理自己的泛型协议时使用。</p>
<h2 id="话题讨论"><a href="#话题讨论" class="headerlink" title="话题讨论"></a>话题讨论</h2><p>4月11日，央行公布了2023年一季度的金融数据，居民超额存款三年10.8万亿：北京人均存款已接近27万，上海人均超21万。<strong>你存钱了吗？你存钱的目的是什么呢？</strong></p>
<ol>
<li>有安全感：为了应对失业、突发疾病等，避免因意外事件而出现经济困难。</li>
<li>实现个人目标：买房、买车、旅行等，通过积累资金来实现自己的愿望。</li>
<li>投资理财：通过投资股票、基金、房地产等资产来增加财富，实现长期的财务目标。</li>
<li>应对退休生活：通过积累养老金和退休金来保障自己的生活质量和经济安全。</li>
<li>没有存款：支出基本等于收入，实在是存不了钱。</li>
</ol>
<p>欢迎在文末留言参与讨论。</p>
<h2 id="关于我们"><a href="#关于我们" class="headerlink" title="关于我们"></a>关于我们</h2><p><strong>Swift社区</strong>是由 Swift 爱好者共同维护的公益组织，我们在国内以微信公众号的运营为主，我们会分享以 <strong>Swift实战</strong>、<strong>SwiftUl</strong>、<strong>Swift基础</strong>为核心的技术内容，也整理收集优秀的学习资料。</p>
<p>欢迎关注公众号:Swift社区，后台点击进群，可以进入我们社区的交流讨论群。希望我们Swift社区是大家在网络空间中的另一份共同的归属。</p>
<p><img width="500" alt="Swift社区" src="https://user-images.githubusercontent.com/24238160/132703149-34121c6c-fd18-491c-a697-58a0fabf3060.png"></p>
<p>特别感谢 Swift社区 编辑部的每一位编辑，感谢大家的辛苦付出，为 Swift社区 提供优质内容，为 Swift 语言的发展贡献自己的力量。</p>

      
    </div>
    
    
    
    

    
      <div>
        <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>

      </div>
    


    
      <div>
        
<div class="my_post_copyright">
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

  <!-- JS库 sweetalert 可修改路径 -->
  <script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  <p><span>本文标题:</span><a href="/Swift-周报-第二十七期/">Swift 周报 第二十七期</a></p>
  <p><span>文章作者:</span><a href="/" title="访问 Swift社区 的个人博客">Swift社区</a></p>
  <p><span>发布时间:</span>2023年07月04日 - 15:07</p>
  <p><span>最后更新:</span>2023年07月04日 - 15:07</p>
  <p><span>原始链接:</span><a href="/Swift-周报-第二十七期/" title="Swift 周报 第二十七期">https://fanbaoying.github.io/Swift-周报-第二十七期/</a>
    <span class="copy-path"  title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="https://fanbaoying.github.io/Swift-周报-第二十七期/"  aria-label="复制成功！"></i></span>
  </p>
  <p><span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
</div>
<script> 
    var clipboard = new Clipboard('.fa-clipboard');
      $(".fa-clipboard").click(function(){
      clipboard.on('success', function(){
        swal({   
          title: "",   
          text: '复制成功',
          icon: "success", 
          showConfirmButton: true
          });
        });
    });  
</script>

      </div>
    


    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechat.png" alt="Swift社区 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.png" alt="Swift社区 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Swift/" rel="tag"><i class="fa fa-tag"></i> Swift</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/Swift-周报-第二十六期/" rel="next" title="Swift 周报 第二十六期">
                <i class="fa fa-chevron-left"></i> Swift 周报 第二十六期
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/Swift-周报-第二十八期/" rel="prev" title="Swift 周报 第二十八期">
                Swift 周报 第二十八期 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
<span class="jiathis_txt">分享到：</span>
<a class="jiathis_button_fav">收藏夹</a>
<a class="jiathis_button_copy">复制网址</a>
<a class="jiathis_button_email">邮件</a>
<a class="jiathis_button_weixin">微信</a>
<a class="jiathis_button_qzone">QQ空间</a>
<a class="jiathis_button_tqq">腾讯微博</a>
<a class="jiathis_button_douban">豆瓣</a>
<a class="jiathis_button_share">一键分享</a>

<a href="http://www.jiathis.com/share?uid=2140465" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank">更多</a>
<a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" >
var jiathis_config={
  data_track_clickback:true,
  summary:"",
  shortUrl:false,
  hideMore:false
}
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js?uid=" charset="utf-8"></script>
<!-- JiaThis Button END -->
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="https://avatars.githubusercontent.com/u/84354365?v=4"
                alt="Swift社区" />
            
              <p class="site-author-name" itemprop="name">Swift社区</p>
              <p class="site-description motion-element" itemprop="description">我们的使命是做一个最专业最权威的 Swift 中文社区，我们的愿景是希望更多的人学习和使用Swift。我们会分享以 Swift 实战、SwiftUI、Swift 基础为核心的技术干货，不忘初心，牢记使命。</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">187</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">19</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">11</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://blog.csdn.net/qq_36478920" target="_blank" title="CSDN">
                      
                        <i class="fa fa-fw fa-heartbeat"></i>CSDN</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://juejin.im/user/5a30d987f265da430d580126" target="_blank" title="掘金">
                      
                        <i class="fa fa-fw fa-spinner"></i>掘金</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/fanbaoying" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.zhihu.com/people/swift-community" target="_blank" title="知乎">
                      
                        <i class="fa fa-fw fa-heartbeat"></i>知乎</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://weibo.com/u/7711465033" target="_blank" title="微博">
                      
                        <i class="fa fa-fw fa-weibo"></i>微博</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://mp.weixin.qq.com/mp/appmsgalbum?__biz=MzAxNzgzNTgwMw==&action=getalbum&album_id=2024314764775981057" target="_blank" title="公众号">
                      
                        <i class="fa fa-fw fa-heartbeat"></i>公众号</a>
                  </span>
                
            </div>
          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                友情链接
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="https://github.com/SwiftCommunityRes/SwiftWeekly" title="SwiftWeekly" target="_blank">SwiftWeekly</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://github.com/SwiftCommunityRes/article-ios" title="Article-ios" target="_blank">Article-ios</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://github.com/SwiftCommunityRes/SwiftUI-Book" title="SwiftUI-Book" target="_blank">SwiftUI-Book</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#新闻和社区"><span class="nav-number">2.</span> <span class="nav-text">新闻和社区</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#苹果公司向“恢复基金”再投2亿美元，推进碳移除项目"><span class="nav-number">2.1.</span> <span class="nav-text">苹果公司向“恢复基金”再投2亿美元，推进碳移除项目</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#因增速放缓-苹果公司将开启大规模收购"><span class="nav-number">2.2.</span> <span class="nav-text">因增速放缓 苹果公司将开启大规模收购</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Swift-Student-Challenge-现已开放申请"><span class="nav-number">2.3.</span> <span class="nav-text">Swift Student Challenge 现已开放申请</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#提案"><span class="nav-number">3.</span> <span class="nav-text">提案</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#通过的提案"><span class="nav-number">3.1.</span> <span class="nav-text">通过的提案</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#正在审查的提案"><span class="nav-number">3.2.</span> <span class="nav-text">正在审查的提案</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Swift论坛"><span class="nav-number">4.</span> <span class="nav-text">Swift论坛</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#推荐博文"><span class="nav-number">5.</span> <span class="nav-text">推荐博文</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#话题讨论"><span class="nav-number">6.</span> <span class="nav-text">话题讨论</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#关于我们"><span class="nav-number">7.</span> <span class="nav-text">关于我们</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="copyright">&copy; <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Swift社区</span>

  
</div>

<!-- 
<div class="powered-by">
  <i class="fa fa-user-md">
  </i>
  <span id="busuanzi_container_site_uv">
    已有<span id="busuanzi_value_site_uv"></span>人来访
  </span>

</div>


  <span class="post-meta-divider">|</span>


<div class="powered-by">
  <i class="fa fa-eye"></i>
  <span id="busuanzi_container_site_pv">
      访问量<span id="busuanzi_value_site_pv"></span>次
  </span>
</div>



  <span class="post-meta-divider">|</span>


-->

<div class="theme-info">
  <i class="fa fa-pencil"></i>
  <span class="post-count">博客全站共361.6k字</span>
</div>


<!-- 
  <span class="post-meta-divider">|</span>



  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>



-->

        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
